/**
 * Baihejia
 * Created by wangguodong on 12/01/2018.
 */
public class Client {

    public static void main(String[] args) throws Exception {
        try {

//            Area area = new Area();
//            area.cityId = 1l;
//            area.name = "test";
//
//            IgniteHelper.save(area);
//
//            System.out.println(JsonHelper.toString(IgniteHelper.findById(Area.class, area.id)));
//
////                    System.out.println(JsonHelper.toString(IgniteHelper.find(Area.class, "cityId=? and id>?", 1, 6000)));
//
//            System.out.println(JsonHelper.toString(IgniteHelper.find("select a.id,c.id from Community.Community a, City.City c where a.cityId=c.id and c.id=2 limit 100")));

//
            IgniteHelper.withTransaction(new IgniteHelper().new Execute() {
                @Override
                public void call() throws Exception {
                    Area area = new Area();
                    area.cityId = 1l;
                    area.name = "test";

                    IgniteHelper.save(area);

                    System.out.println(JsonHelper.toString(IgniteHelper.findById(Area.class, area.id)));

                    System.out.println(JsonHelper.toString(IgniteHelper.find(Area.class, "cityId=? and id>=?", 80000, area.id)));

                    System.out.println();
//                    System.out.println(JsonHelper.toString(IgniteHelper.find("select a.id from base.City a limit 100")));
//                    System.out.println(JsonHelper.toString(IgniteHelper.find("select a.id from base.Community a limit 100")));
                }
            });

//            System.out.println(JsonHelper.toString(IgniteHelper.find("select a.id,c.id from base.Community a, base.City c where a.cityId=c.id and c.id=2 limit 100")));

        } finally {
            IgniteHelper.close();
        }
    }
}